# 京东商城爬取
import requests

import io
import sys
sys.stdout = io.TextIOWrapper(sys.stdout.buffer,encoding='utf-8')

def getHTMLText(url):
	try:
		kv = {'user-agent':'Mozilla/5.0'}
		r = requests.get(url,timeout=30,headers = kv)
		print(r.headers)
		print(r.request.headers)
		r.raise_for_status()
		r.encoding = r.apparent_encoding
		return r.text[:1000]
	except Exception as e:
		print(e)
		return '产生异常'
			
if __name__ == '__main__':
	url = 'http://item.jd.com/100002433194.html'
	print(getHTMLText(url))